package com.nwpusp.display.views.components;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.view.View;

import com.example.petssports.R;
import com.nwpusp.display.GlobalVar;

public class GameProcessBar extends View{
	private Bitmap bgBitmap;
	public float x;
	public float y;
	public float scale;
	public float width;
	public float height;
	 
	public GameProcessBar(Context view,float scale){
		super(view);
		this.scale = scale;
		getBitmapSource();
		bgBitmap = GlobalVar.HorizontalScale(bgBitmap,scale);
		bgBitmap = FixHeight(bgBitmap,GlobalVar.screenHeight/18);
		width = bgBitmap.getWidth();
		height = bgBitmap.getHeight();
		x =  (GlobalVar.screenWidth - width)*GlobalVar.half;
		y = GlobalVar.screenHeight - height;
	}
	
	private void getBitmapSource(){
		bgBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.gameprocessbar);
	}
		
	public Bitmap draw(){
		return bgBitmap;
	}
	
	public static Bitmap FixHeight(Bitmap bitmap,float newHeight){
		 int width = bitmap .getWidth();  
		 int height = bitmap .getHeight();
		 float scale = newHeight/height;
	     Matrix matrix = new Matrix();  
	     matrix.postScale(1,scale);
	     Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height,matrix,true);  	 
	     return resizedBitmap;
	}
}
